<div id="d1"></div>
<input type="button" value="暂停" onclick="stopTime()" />
<meta charset="UTF-8">
<script>
    d1.innerHTML = new Date();

    function f(){
        d1.innerHTML = new Date();
    }

    var timer = setInterval(f,1000);

    function stopTime(){
        clearInterval(timer);
    }
</script>
